import { selGoodsByBT } from '../services/homeGoods'


export default {

  namespace: 'tableGoods',

  state: {
      goodsList:[]
  },



  effects: {
    *selGoods4BT({ payload }, { call, put }){
      let index = payload.index
      delete payload[index];
      const resp = yield call(selGoodsByBT,payload)
      yield put(
        { type: 'selGoods' ,
          state: {
            tmp:resp.data.data,
            index:index
          }
        }
      );
      return resp;
    }
  },

  reducers: {
    selGoods(state, action) {
        state.goodsList[action.state.index] = action.state.tmp; 
        action.state.goodsList = state.goodsList; 
      return { ...state, ...action.state };
    }
  },

};
